﻿/*************************************************************************
 * Created by OhZee Creative, LLC
 * 2013
 * This code is licensed under Microsoft Public License (Ms-PL)
 * http://opensource.org/licenses/ms-pl
 * http://ozframework.codeplex.com/
 *************************************************************************/

namespace OhZeeCreative.Metadata
{
    using System.Collections.Generic;

#if SILVERLIGHT
    using System.Windows;
#endif
#if NETFX_CORE
    using Windows.UI.Xaml;
#endif
    public class ControlMetadata : MetadataBase
	{
        private Dictionary<string, MetadataBase> properties;

        public ControlMetadata(string description) : base(description) { }

        public ControlMetadata(string description, params MetadataEntry[] propertyMetadata) : this(description) 
        {
            this.properties = new Dictionary<string, MetadataBase>(propertyMetadata.Length);

            foreach (MetadataEntry entry in propertyMetadata)
            {
                this.properties.Add(entry.Key, entry.Metadata);
            }    
        }


		public HorizontalAlignment? HorizontalAlignment { get; set; }
		public VerticalAlignment? VerticalAlignment { get; set; }
		public double? Width { get; set; }
		public double? Height { get; set; }

		public string DemoContent { get; set; } // A valid XAML snippet

        public MetadataBase Property(string propertyName)
        {
            MetadataBase metadata;
            if (this.properties != null && this.properties.TryGetValue(propertyName, out metadata))
            {
                return metadata;
            }

            return null;
        }
	}
}
